import React, { lazy, Suspense } from "react";
import { BrowserRouter as Router, Route, Redirect } from "react-router-dom";
import NavBar from "../components/navbar"
const Regpage = lazy(() => import("../pages/reg"));
const Loginpage = lazy(() => import("../pages/login"));
const Home = lazy(() => import("./homeRouter"));

class RouterComponent extends React.Component {
    render() {
        return(

            <React.Fragment>
                <Router>
                <React.Fragment>
                {/* <NavBar> */}
                {/* </NavBar> */}
                {/* <div className="main"> */}
                <Suspense fallback={<div>loading</div>}>
                <Route path="/reg" component={Regpage}></Route>
                <Route path="/login" component={Loginpage}></Route>
                <Route path="/home" component={Home}></Route>
                <Route
                path="/"
                exact
                render={() => <Redirect to="/home" />}
              ></Route>
                </Suspense>
                {/* </div> */}
                </React.Fragment>
                </Router>
            </React.Fragment>
        )
    }
}
export  default RouterComponent;